cmake_minimum_required(VERSION 3.10)
project (main)

include(ExternalProject)
# set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
# 1.设置可执行文件的输出路径：
# PROJECT_SOURCE_DIR：工程的根目录
# PROJECT_BINARY_DIR：运行cmake命令的目录，通常为${PROJECT_SOURCE_DIR}/build
# PROJECT_NAME：返回通过 project 命令定义的项目名称
# CMAKE_CURRENT_SOURCE_DIR：当前处理的 CMakeLists.txt 所在的路径
# CMAKE_CURRENT_BINARY_DIR：target 编译目录
# CMAKE_CURRENT_LIST_DIR：CMakeLists.txt 的完整路径
# EXECUTABLE_OUTPUT_PATH：重新定义目标二进制可执行文件的存放位置
# LIBRARY_OUTPUT_PATH：重新定义目标链接库文件的存放位置

SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
# 2.静态库 lib 输出路径：

# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/…/bin)

# 3.动态库输出路径（注意这个放在最后）：
# SET_TARGET_PROPERTIES(dllname PROPERTIES RUNTIME_OUTPUT_DIRECTORY …/bin)

aux_source_directory (src SRC_LIST)
include_directories (include)

find_library(REALTIME_LIB rt)
if (REALTIME_LIB)
    list(APPEND EXTERNAL_LIBS PRIVATE rt)
endif()

include(cmake/glog.cmake)
list(APPEND EXTERNAL_LIBS PRIVATE ${glog_LIBRARIES})
list(APPEND EXTERNAL_INCS PRIVATE ${glog_INCLUDE_DIRS})

add_executable (main ${SRC_LIST})

find_package(Threads REQUIRED)
find_package(gflags REQUIRED)

add_dependencies(main glog)
target_include_directories(main ${EXTERNAL_INCS})
target_link_libraries(main ${EXTERNAL_LIBS} ${CMAKE_THREAD_LIBS_INIT} gflags)

